package com.jack.thinking.java._22.swing.pane;

import java.awt.Component;
import java.awt.FlowLayout;

import javax.swing.*;

import com.utils.SwingConsole;

public class LookAndFeel extends JFrame{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String[] choices = "Eeny Meeny Minnie Mickey Moe Larry Curly".split(" ");
	
	private Component[] samples = {
			new JButton("JButton"),
			new JTextField("JTextField"),
			new JLabel("JLabel"),
			new JCheckBox("JCheckBox"),
			new JRadioButton("JRadioButton"),
			new JComboBox<String>(choices),
			new JList<String>(choices)
	};
	
	public LookAndFeel() {
		super("Look And Feel");
		setLayout(new FlowLayout());
		for (Component component : samples) {
			add(component);
		}
	}
	
	private static void usageError() {
		System.out.println("Uage: LookAndFeel ");
		System.exit(1);
	}
	
	public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
		if(args.length == 0) usageError();
		if(args[0].equals("cross")) {
			UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
		}else if(args[0].equals("system")) {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}else if(args[0].equals("motif")) {
			UIManager.setLookAndFeel("com.sun.java." + "swing.plaf.motif.MotifLookAndFeel");
		}else {
			usageError();
		}
		
		SwingConsole.run(new LookAndFeel(), 300, 300);
	}
}
